﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twodi.Aspect.Interfaces;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Twodi.Interfaces;

namespace Twodi.Aspect.Implemented
{
    /// <summary>
    /// Define um componente que possui tamanho.
    /// </summary>
    public class SizeAspect : AbstractAspect, ISize
    {
        /// <summary>
        /// Tamanho do componente.
        /// </summary>
        private Vector2 size;

        /// <summary>
        /// Posição central do componente.
        /// </summary>
        public Vector2 Center
        {
            get
            {
                return Vector2.Divide(this.Size, 2);
            }
        }

        /// <summary>
        /// Largura do componente.
        /// </summary>
        public float Width
        {
            get
            {
                return Size.X;
            }
        }

        /// <summary>
        /// Altura do componente.
        /// </summary>
        public float Height
        {
            get
            {
                return this.Size.Y;
            }
        }

        /// <summary>
        /// Tamanho do componente.
        /// </summary>
        public Vector2 Size
        {
            get
            {
                return this.size;
            }
            set
            {
                OnPropertyChanged<Vector2>("Size", ref size, value);
            }
        }

        /// <summary>
        /// Evento invocado quando tamanho for alterado.
        /// </summary>
        public event EventHandler SizeChanged;

        /// <summary>
        /// Método invocado no momento que o tamanho é alterado.
        /// </summary>
        /// <param name="e"></param>
        protected void onSizeChanged(EventArgs e)
        {
            if (SizeChanged != null) SizeChanged(this, e);
        }
    }
}
